<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>操作样式</button>
    <div style="width:100px; height:100px; background-color: pink;">文本内容</div>

    <script>
        // 获取元素
        var box = document.querySelector('div')
        var btn = document.querySelector('button')
        // 获取行内样式
        // console.log(box.style.width)
        // console.log(box.style.height)
        // console.log(box.style.backgroundColor)
        // 获取非行内样式以及行内样式
        console.log(window.getComputedStyle(box).width)
        console.log(window.getComputedStyle(box).height)
        console.log(window.getComputedStyle(box).backgroundColor)

        // 点击事件
        btn.onclick = function (){
            // 设置div的样式
            box.style.width = '200px'
            box.style.height = '300px'
            box.style.backgroundColor = 'skyblue'
        }
    </script>
</body>
</html>